// nuxt 配置文件
export default {
    server: {
        host: '0.0.0.0',
        port: 3003
    },
    proxy: {
        '/api': {
            target: 'https://conduit.productionready.io', // 目标接口域名
            pathRewrite: {
                '^/api': '/', // 把 /api 替换成 /
                changeOrigin: true // 表示是否跨域
            }
        }
    },
    router: {
        // 配置路由高亮
        linkActiveClass: 'active',
        // 自定义路由规则
        extendRoutes(routes, resolve) {
            // 清楚 nuxt.js 基于 pages 目录表自动生成的路由规则表
            routes.splice(0)
            routes.push(...[
                {
                    path: '/',
                    component: resolve(__dirname, 'pages/layouts'),
                    children: [
                        {
                            path: '', //默认子路由
                            name: 'home',
                            component: resolve(__dirname, 'pages/home')
                        },
                        {
                            path: '/login',
                            name: 'login',
                            component: resolve(__dirname, 'pages/login'),
                        },
                        {
                            path: '/register',
                            name: 'register',
                            component: resolve(__dirname, 'pages/login'),
                        },
                        {
                            path: '/profile/:username',
                            name: 'profile',
                            component: resolve(__dirname, 'pages/profile'),
                        },
                        {
                            path: '/editor',
                            name: 'editor',
                            component: resolve(__dirname, 'pages/editor'),
                        },

                        {
                            path: '/settings',
                            name: 'settings',
                            component: resolve(__dirname, 'pages/settings'),
                        },
                        {
                            path: '/article/:slug',
                            name: 'article',
                            component: resolve(__dirname, 'pages/Article'),
                        }
                    ]
                },

            ])
        }
    },
    // 注册插件
    plugins:[
        '~/plugins/request.js',
        '~/plugins/dayjs.js',
    ]

}